package com.sdap2.common.controller;

import com.sdap2.common.entity.LogicEntity;
import com.sdap2.common.service.LogicService;
import org.springframework.web.bind.annotation.*;

public abstract class LogicController<T extends LogicEntity> {
    
    protected abstract LogicService<T> getService();
    
    @PostMapping
    public T create(@RequestBody T entity) {
        return getService().save(entity);
    }
    
    @GetMapping("/{id}")
    public T getById(@PathVariable Long id) {
        return getService().findById(id);
    }
    
    @PutMapping("/{id}")
    public T update(@PathVariable Long id, @RequestBody T entity) {
        entity.setId(id);
        return getService().save(entity);
    }
    
    @DeleteMapping("/{id}")
    public void delete(@PathVariable Long id) {
        getService().deleteById(id);
    }
} 